package com.nacosclient.nacosclient;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class NacosClient {

	private final RestTemplate restTemplate;

	@Autowired
	public NacosClient(RestTemplate restTemplate) {this.restTemplate = restTemplate;}

	@Autowired
	private FeignClientService feignClientService;



	@GetMapping("/test")
	public String test() {
		return restTemplate.getForObject("http://userserver/test", String.class);
	}

	@GetMapping("/test2")
	public String test2(){
		System.out.println(111);
		return feignClientService.test2();
	}
	@GetMapping("/test3")
	@HystrixCommand(fallbackMethod = "fallback")
	public String test3(){
		return feignClientService.test3();
	}

	public String fallback(){
		return "time2000";
	}

	@GetMapping("/test4")
	public String test4(){
		return feignClientService.test3();
	}
	@GetMapping("/test5")
	public String test5(){
		FeignBuildApi feignBuildApi=new FeignBuildApi();
		return feignBuildApi.getClientTest().test2();
	}

	@GetMapping("/test6")
	public String test6(){
		FeignBuildApi feignBuildApi=new FeignBuildApi();
		return feignBuildApi.getClientTest1().test3();
	}

}
